﻿Imports System.Diagnostics
Imports System.Windows.Forms
Imports Microsoft.Win32

Public Class Main

    Private f_traCuu As TraCuuBV
    Private f_BanVe As BanVe
    Public f_HanhKhach As ThemHanhKhach
    Public f_tracuuhk As TraCuuHK
    Public f_tracuuhv As TraCuuHV

    Private Sub Main_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Set up the UI
        TreeView.ExpandAll()
    End Sub

    Private Sub LoadListView()

    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'Close this form
        Me.Close()
    End Sub

    Private Sub ToolBarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub StatusBarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    End Sub

    'Change whether or not the folders pane is visible
    Private Sub ToggleFoldersVisible()
        SplitContainer.Panel1Collapsed = Not SplitContainer.Panel1Collapsed
    End Sub

    Private Sub FoldersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        ToggleFoldersVisible()
    End Sub

    Private Sub FoldersToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FoldersToolStripButton.Click
        ToggleFoldersVisible()
    End Sub

    Private Sub OpenToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim OpenFileDialog As New OpenFileDialog
        OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
        OpenFileDialog.Filter = "Text Files (*.txt)|*.txt"
        OpenFileDialog.ShowDialog(Me)

        Dim FileName As String = OpenFileDialog.FileName
        ' TODO: Add code to open the file
    End Sub

    Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim SaveFileDialog As New SaveFileDialog
        SaveFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
        SaveFileDialog.Filter = "Text Files (*.txt)|*.txt"
        SaveFileDialog.ShowDialog(Me)

        Dim FileName As String = SaveFileDialog.FileName
        ' TODO: Add code here to save the current contents of the form to a file.
    End Sub

    Private Sub TreeView_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView.AfterSelect
        Dim bus_sanbay As New BUS.SanBay
        Dim bus_chuyenbay As New BUS.ChuyenBay
        Dim bus_hanhkhach As New BUS.TraCuuKH
        Dim bus_banve As New BUS.TraCuuBV
        Dim bus_datve As New BUS.DatVe
        If e.Node.Text = "Sân bay" Then
            DataGridView.DataSource = bus_sanbay.lay_dataset_san_bay_co_tham_chieu.Tables(0)
        ElseIf e.Node.Text = "Chuyến bay" Then
            DataGridView.DataSource = bus_chuyenbay.lay_dataset_chuyen_bay.Tables(0)
        ElseIf e.Node.Text = "Hành khách" Then
            DataGridView.DataSource = bus_hanhkhach.laydthanhkhach.Tables(0)
        ElseIf e.Node.Text = "Danh sách đặt vé" Then
            'DataGridView.DataSource = bus_chuyenbay.lay_dataset_chuyen_bay.Tables(0)
        ElseIf e.Node.Text = "Danh sách vé bán" Then
            DataGridView.DataSource = bus_banve.dtload.Tables(0)
        End If

    End Sub

    Private Sub ThayĐổiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThayĐổiToolStripMenuItem.Click
        Dim f_thamSo = New ThamSo
        f_thamSo.Show()
    End Sub

    Private Sub TraCứuToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TraCứuToolStripMenuItem1.Click
        If IsNothing(f_traCuu) Then
            f_traCuu = New TraCuuBV
        End If
        f_traCuu.Show()
    End Sub

    Private Sub MuaVéToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MuaVéToolStripMenuItem1.Click
        If IsNothing(f_BanVe) Then
            f_BanVe = New BanVe
        End If
        f_BanVe.Show()
    End Sub

    Private Sub ThêmMớiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThêmMớiToolStripMenuItem.Click
        If IsNothing(f_HanhKhach) Then
            f_HanhKhach = New ThemHanhKhach
        End If
        f_HanhKhach.Show()
    End Sub

    Private Sub TraCứuToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TraCứuToolStripMenuItem.Click
        If IsNothing(f_tracuuhk) Then
            f_tracuuhk = New TraCuuHK
        End If
        f_tracuuhk.Show()
    End Sub

    Private Sub ĐặtVéToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ĐặtVéToolStripMenuItem1.Click
        Dim f_datve = New DatVe
        Dim ketqua = f_datve.ShowDialog()
    End Sub

    Private Sub ThêmmớiToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThêmmớiToolStripMenuItem1.Click
        Dim f As New ChuyenBay
        f.ShowDialog()
    End Sub

    Private Sub ThêmMớiToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThêmMớiToolStripMenuItem3.Click
        Dim f As New HangVe
        f.Show()
    End Sub

    Private Sub TraCứuToolStripMenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TraCứuToolStripMenuItem5.Click
        Dim f As New TraCuuHV
        f.Show()
    End Sub

End Class
